﻿using System;
using System.Collections.Generic;
using System.Text;
using PluginFramework;

namespace PocketPatients
{
    class PluginBroker : PluginLoader
    {
        private PluginBroker()
        { }

        public static IPlugin Load(string name)
        {
            Type InputElementClass = FindAssembly("PocketPatientsPlugins", name, SharedData.GetApplicationDirectory(), typeof(IPlugin));
            if (InputElementClass == null)
                throw new Exception("Type Not Found");

            return InputElementClass.GetConstructor(new Type[0]).Invoke(new Type[0]) as IPlugin;
        }

        public static string[] List()
        {
            Type[] TypeList = FindAllAssemblies("PocketPatientsPlugins", SharedData.GetApplicationDirectory(), typeof(IPlugin));
            string[] Result = new string[TypeList.Length];
            for (int I = 0; I < TypeList.Length; I++)
                Result[I] = TypeList[I].ToString();

            return Result;
        }
    }
}
